<?php

declare(strict_types=1);
/*
 * 管理后台接口地址
 * Author: Zane
 * Email: 873934580@qq.com
 * Date: 2023/5/24
 */

use App\Http\Controllers\System;
use Illuminate\Support\Facades\Route;

// 不登录接口地址
Route::group(['prefix' => getRoutePrefix()], function (): void {
    Route::post('login', [System\LoginController::class, 'login']);
});

Route::group(['prefix' => getRoutePrefix(), 'middleware' => ['auth:system']], function (): void {
    // 退出登录
    Route::get('logout', [System\LoginController::class, 'logout']);
    Route::post('upload', [System\UploadController::class, 'upload']);

    // 操作日志
    Route::get('logs', [System\LogController::class, 'index']);
    Route::get('logs/{id}', [System\LogController::class, 'details']);

    // 系统人员管理
    Route::get('login-log', [System\SystemController::class, 'loginLog']);
    Route::get('systems', [System\SystemController::class, 'index']);
    Route::put('systems/{id}', [System\SystemController::class, 'edit']);
    Route::put('my-system', [System\SystemController::class, 'myEdit']);
    Route::put('systems-status/{id?}', [System\SystemController::class, 'status']);
    Route::delete('systems/{id?}', [System\SystemController::class, 'delete']);
    Route::post('systems', [System\SystemController::class, 'store']);
    Route::get('my-permission', [System\SystemController::class, 'myPermission']);

    // 系统角色管理
    Route::get('roles', [System\RoleController::class, 'index']);
    Route::put('roles/{id}', [System\RoleController::class, 'edit']);
    Route::delete('roles/{id?}', [System\RoleController::class, 'delete']);
    Route::post('roles', [System\RoleController::class, 'store']);

    // 角色设置权限
    Route::post('roles-permission/{id}', [System\RoleController::class, 'setPermission']);
    Route::get('roles-permission/{id}', [System\RoleController::class, 'getPermission']);

    // 权限管理
    Route::get('permissions', [System\PermissionController::class, 'index']);
    Route::get('permissions-lists', [System\PermissionController::class, 'lists']);
    Route::put('permissions/{id}', [System\PermissionController::class, 'edit']);
    Route::delete('permissions/{id?}', [System\PermissionController::class, 'delete']);
    Route::post('permissions', [System\PermissionController::class, 'store']);

    // 栏目管理
    Route::get('categories', [System\CategoryController::class, 'index']);
    Route::get('categories-tree', [System\CategoryController::class, 'tree']);
    Route::post('categories', [System\CategoryController::class, 'store']);

    // 广告管理
    Route::get('ads', [System\AdController::class, 'index']);
    Route::put('ads/{id}', [System\AdController::class, 'edit']);
    Route::delete('ads/{id?}', [System\AdController::class, 'delete']);
    Route::post('ads', [System\AdController::class, 'store']);

    // 广告位置管理
    Route::get('ad-positions', [System\AdPositionController::class, 'index']);
    Route::put('ad-positions/{id}', [System\AdPositionController::class, 'edit']);
    Route::delete('ad-positions/{id?}', [System\AdPositionController::class, 'delete']);
    Route::post('ad-positions', [System\AdPositionController::class, 'store']);

    // 环境分类配置
    Route::get('configures-cates', [System\ConfigureCateController::class, 'index']);
    Route::post('configures-cates', [System\ConfigureCateController::class, 'store']);
    Route::put('configures-cates/{id}', [System\ConfigureCateController::class, 'edit']);
    Route::delete('configures-cates/{id?}', [System\ConfigureCateController::class, 'delete']);

    // 环境字段配置
    Route::get('configures', [System\ConfigureController::class, 'index']);
    Route::post('configures', [System\ConfigureController::class, 'store']);
    Route::put('configures/{id}', [System\ConfigureController::class, 'edit']);
    Route::delete('configures/{id?}', [System\ConfigureController::class, 'delete']);

    // 模型管理
    Route::get('channel-models', [System\ChannelModelController::class, 'index']);
    Route::get('channel-lists', [System\ChannelModelController::class, 'lists']);
    Route::post('channel-models', [System\ChannelModelController::class, 'store']);
    Route::put('channel-models/{id}', [System\ChannelModelController::class, 'edit']);
    Route::delete('channel-models/{id}', [System\ChannelModelController::class, 'del']);

    // 模型字段管理
    Route::get('model-fields/{id}', [System\ChannelFieldController::class, 'index']);
    Route::post('model-fields/{id}', [System\ChannelFieldController::class, 'store']);
    Route::delete('model-fields/{id}', [System\ChannelFieldController::class, 'index']);

    // 内容管理
    Route::get('archives', [System\ArchivesController::class, 'index']);

    // 文章管理
    Route::get('article', [System\ArticleController::class, 'index']);
    Route::post('article', [System\ArticleController::class, 'store']);
    Route::put('article/{id}', [System\ArticleController::class, 'edit']);
    Route::delete('article/{id?}', [System\ArticleController::class, 'delete']);

    // 产品管理
    Route::get('liquor', [System\LiquorController::class, 'index']);
    Route::post('liquor', [System\LiquorController::class, 'store']);
    Route::put('liquor/{id}', [System\LiquorController::class, 'edit']);
    Route::delete('liquor/{id?}', [System\LiquorController::class, 'delete']);
});
